﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace LastfmNet.Models
{
    public class Affiliation : LastfmModelBase
    {
        public Affiliation()
        {
            this.SupplierName = string.Empty;
            this.Price = new Price();
            this.BuyLink = string.Empty;
            this.SupplierIcon = string.Empty;
            this.IsSearch = false;
        }

        public Affiliation(XmlNode affiliationNode)
            : this()
        {
            if (affiliationNode == null) return;
            this.InitializeFromXmlNode(affiliationNode);
        }

        public override void InitializeFromXmlNode(XmlNode node)
        {
            if (node == null) return;
            this.SupplierName = node.GetChildValue("supplierName");
            this.Price = new Price(node.GetChild("price"));
            this.BuyLink = node.GetChildValue("buyLink");
            this.SupplierIcon = node.GetChildValue("supplierIcon");
            this.IsSearch = node.GetChildValue("isSearch").ToBoolean();
        }

        public string SupplierName
        {
            get;
            set;
        }

        public Price Price
        {
            get;
            set;
        }

        public string BuyLink
        {
            get;
            set;
        }

        public string SupplierIcon
        {
            get;
            set;
        }

        public bool IsSearch
        {
            get;
            set;
        }
    }
}
